<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="丁浛峻">
    <title></title>
    <style>
        body{
            margin: 0;
        }
        ul{
            list-style: none;
            margin: 0;
            padding: 0;
        }
        .container{
             width: 820px; 
             height: 325px; 
            margin: 0 auto;
            border: 1px solid lightpink;
            border-collapse: collapse;
        }
        ul li{
            float: left;
        }
        li{
            width: 150px;
            height: 150px;
             border: 1px solid gray; 
            position: relative;
            margin: 5px;
            background-color: #666;
        }
        li img{
             display: none; 
            position: absolute;
            top: 0;
            margin: 10px 0 0 10px;
            z-index: 9999;
        }
        li div{
            padding-top: 40px;
             text-align: center;
            width: 100%;
            height: 100%;
            line-height: 100%;  
            /* z-index: 999; */
            
            
        }
        p{
            margin: 0;
        }
        .current{
            display: block;
            transform: scale(1.5,1.5);
        }
    </style>
</head>
<body>

    <div class="container">
        <ul>
            <li>
                <div>
                    <p>BMW</p>
                    <p>宝马汽车</p>
                </div>
                <img src="img/1.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                   <p>宝马汽车</p>
                </div>
                <img src="img/2.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                   <p>宝马汽车</p>
                </div>
                <img src="img/3.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                    <p>宝马汽车</p>
                </div>
                <img src="img/4.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                   <p>宝马汽车</p>
                </div>
                <img src="img/5.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                   <p>宝马汽车</p>
                </div>
                <img src="img/6.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                    <p>宝马汽车</p>
                </div>
                <img src="img/7.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                   <p>宝马汽车</p>
                </div>
                <img src="img/8.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                    <p>宝马汽车</p>
                </div>
                <img src="img/9.jpg" alt="">
            </li>
            <li>
                <div>
                    <p>BMW</p>
                   <p>宝马汽车</p>
                </div>
                <img src="img/10.jpg" alt="">
            </li>
        </ul>
    </div>
</body>

<script>

    var lis = document.querySelectorAll('li');
    var imgs = document.querySelectorAll('img');
    for(var i = 0; i < lis.length; i++){
        lis[i].index = i;
            lis[i].onmouseover = function(){
            imgs[this.index].className = 'current';
        }
            lis[i].onmouseout = function(){
            imgs[this.index].className = '';
        }
    }



</script>
</html>